<template>
  <div class="account-settings-info-view">
    <div class="title">报警设置</div>
    <a-form-model layout="vertical" style="max-width: 650px;margin-top: 12px">
      <a-form-model-item label="企业ID">
        <a-input placeholder="请输入企业ID" v-model="settings.corp_id"/>
      </a-form-model-item>
      <a-form-model-item label="AgentId">
        <a-input placeholder="请输入AgentId" v-model="settings.agent_id"/>
      </a-form-model-item>
      <a-form-model-item label="Secret">
        <a-input placeholder="请输入Secret" v-model="settings.secret"/>
      </a-form-model-item>
      <a-form-model-item>
        <a-button type="primary" @click="submitKetInfo">保存设置</a-button>
      </a-form-model-item>
    </a-form-model>
  </div>
</template>

<script>
  import * as api from '@/api/system/settingManage'
  import { mapGetters } from 'vuex'

  export default {
    computed: {
      ...mapGetters(['settings'])
    },
    methods: {
      submitKetInfo() {
        const dataList = [
          { key: 'corp_id', value: this.settings.corp_id },
          { key: 'agent_id', value: this.settings.agent_id },
          { key: 'secret', value: this.settings.secret }
        ]
        api.addObj({ data: dataList }).then((res) => {
          if (res.success) {
            this.$message.success('微信报警配置更新成功！')
          } else {
            this.$message.error(res.message)
          }
        })
      }
    }
  }
</script>

<style lang="less" scoped>
</style>

